import { Component, PropsWithChildren } from 'react'
import { View, Text, Image, RichText } from '@tarojs/components'

import './index.scss'


export default class RichTextCp extends Component<PropsWithChildren> {
  constructor(props) {
    super(props);

    this.state = {
      contents:''
    };
  }
  componentWillMount() { }

  componentDidMount() { }

  componentWillUnmount() { }

  componentDidShow() { }

  componentDidHide() { }

  processRichText = (str) => {
    if (str) {
      return str.replace(/<img/gi, '<img style="max-width:100%;height:auto;display:block"')
    }
    return ''

  }
  render() {
    const { contents } = this.state;
    return (
      <View className='index'>
        <View className="content">
          <RichText nodes={this.processRichText(contents)}></RichText>
        </View>
      </View>
    )
  }
}
